<script setup lang="ts">
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app'
import { useWayBillListApi } from "@/apis/order"
import { waybilltype, waybillstate, waybillSettlementStatus } from "@/utils/format"

let id: string

onLoad((e)=>{
	id = e?.id
	getData()
})


const dataList = ref<any>([])

function getData(){
	useWayBillListApi(id).then((res) =>{
		dataList.value = res
	})
}

function openInfo(id){
	uni.navigateTo({
		url: "/pages/order/waybillInfo?id=" + id
	})
}
</script>
<template>
	<scroll-view style="padding: 0 20rpx;" scroll-y show-scrollbar>
		<view v-for="(item, index) in dataList" :key="item" class="order_item" @click="openInfo(item.id)">
			<view class="item">运单编号：{{item.id}}&nbsp;第{{index + 1}}次</view>
			<view class="item"><text>运单类型：{{waybilltype(item.type)}}</text><text>运单状态：{{waybillstate(item.state)}}</text></view>
			<view class="item" v-show="item.state === 2"><text>结算状态：{{waybillSettlementStatus(item.settlementStatus)}}</text><text>信用评分：</text></view>
			<view class="item">接单时间：{{item.startTime}}</view>
			<view class="item" v-show="item.state === 2">完成时间：{{item.endTime}}</view>
		</view>
	</scroll-view>
</template>

<style>
page{
	background: linear-gradient(to bottom, #edd9fd 10% ,#d8c6e6 20%, #F8F8F8 100%);
}
.order_item{
	position: relative;
	background-color: #fff;
	margin: 10px 0;
	padding: 5px 10px;
	border-radius: 5px;
	font-size: 24rpx;
}
.item{
	display: flex;
}
.item>text{
	flex: 1
}
</style>